#include <iostream>
#include <algorithm>
#include <cstdio>
#include <array>
#include <vector>
using namespace std;
#ifdef ONLINE_JUDGE

#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 23], *p1 = buf, *p2 = buf, ubuf[1 << 23], *u = ubuf;

#endif
int read() {
	int p = 0, flg = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') flg = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		p = p * 10 + c - '0';
		c = getchar();
	}
	return p * flg;
}
void write(int x) {
	if (x < 0) {
		x = -x;
		putchar('-');
	}
	if (x > 9) {
		write(x / 10);
	}
	putchar(x % 10 + '0');
}
bool _stmer;

const int N = 1e6 + 5;

array <int, N> idx;

bool _edmer;
int main() {
	cerr << (&_stmer - &_edmer) / 1024.0 / 1024.0 << "MB\n";
#ifndef cxqghzj
	freopen("permutation.in", "r", stdin);
	freopen("permutation.out", "w", stdout);
#endif
	int n = read(), k = read();
	if (k == 2 && n > 8) {
		write(3), putchar(32);
		write(1), putchar(32);
		write(2), putchar(32);
		for (int i = 4; i <= n - 2; i++)
			write(i), putchar(32);
		write(n), putchar(32);
		write(n - 1), puts("");
		return 0;
	}
	vector <vector <int> > qrl;
	for (int i = 1; i <= n; i++) idx[i] = i;
	do {
		bool flg = 0;
		int res = idx[1];
		for (int i = 2; i <= n; i++)
			flg |= res <= idx[i], res += idx[i];
		if (flg) continue;
		vector <int> tp;
		for (int i = 1; i <= n; i++) tp.push_back(idx[i]);
		qrl.push_back(tp);
	} while (next_permutation(idx.begin() + 1, idx.begin() + 1 + n));
	sort(qrl.begin(), qrl.end());
	for (auto p : qrl[k - 1])
		write(p), putchar(32);
	puts("");
	return 0;
}
